package com.bestcem.xm.om.controller.param;

import com.bestcem.xm.om.entity.EmailBox;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author zq.ding <zq.ding@idiaoyan.com>
 * @version v1.0
 * @date 2021/11/18 11:17
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class EmailParam {
    /**
     * 账户名
     */
    @JsonProperty(value = "account")
    private String account;

    /**
     * 密码
     */
    @JsonProperty(value = "password")
    private String password;

    /**
     * 远程主机,例如: smtp.exmail.qq.com
     */
    @JsonProperty(value = "host")
    private String host;

    /**
     * 端口号
     */
    @JsonProperty(value = "port")
    private Integer port;

    /**
     * 备注,可有可无,看产品有无这个需求
     */
    @JsonProperty(value = "description")
    private String description;

    /**
     * 是否ssl
     */
    @JsonProperty(value = "ssl")
    private Boolean ssl;

    /**
     * 验证状态
     */
    @JsonProperty(value = "validate_status")
    private Boolean validateStatus;

    public static EmailBox convertToMailBox(EmailParam param) {

        EmailBox emailBox = new EmailBox();
        emailBox.setAccount(param.getAccount());
        emailBox.setPassword(param.getPassword());
        emailBox.setHost(param.getHost());
        emailBox.setPort(param.getPort());
        emailBox.setDescription(param.getDescription());
        emailBox.setSsl(param.getSsl());
        return emailBox;
    }
}
